import { PaginationParam, PaginationResult } from "../../models";
import req from "../../req";
import { EquipmentTypeItem, ParEquipmentTypeItem } from "../equipment/models";
import { EquipmentCategoryItem } from "../equipmentCategory/models";
import { DeviceTypeItem, ParDeviceTypeItem } from "./models";

// 平台端
export enum Api {
  addEquipmentTypes = "api/system/equipmentTypes/addEquipmentTypes",
  deleteEquipmentTypeByIds = "api/system/equipmentTypes/deleteEquipmentTypeByIds",
  getEquipmentTypeTreeVoByName = "api/system/equipmentTypes/getEquipmentTypeTreeVoByName",
  updateEquipmentTypes = "api/system/equipmentTypes/updateEquipmentTypes",
  pageEquipmentCategory = "api/aiot/defaultEquipmentCategory/pageEquipmentCategory",
  saveOrUpdateEquipmentCategory = "api/aiot/defaultEquipmentCategory/saveOrUpdateEquipmentCategory",
  deleteEquipmentCategoryByIds = "api/aiot/defaultEquipmentCategory/deleteEquipmentCategoryByIds",
  equipmentPage = "api/system/equipmentTypes/page",
  copyEquipmentTypes = "api/aiot/equipmentType/copyEquipmentTypes",
}
// 企业端
export enum Api_aiot {
  addEquipmentTypes = "api/aiot/equipmentType/addEquipmentTypes",
  deleteEquipmentTypeByIds = "api/aiot/equipmentType/deleteEquipmentTypeByIds",
  getEquipmentTypeTreeVoByName = "api/aiot/equipmentType/getEquipmentTypeTreeVoByName",
  updateEquipmentTypes = "api/aiot/equipmentType/updateEquipmentTypes",
  pageEquipmentCategory = "api/aiot/equipmentCategory/pageEquipmentCategory",
  saveOrUpdateEquipmentCategory = "api/aiot/equipmentCategory/saveOrUpdateEquipmentCategory",
  deleteEquipmentCategoryByIds = "api/aiot/equipmentCategory/deleteEquipmentCategoryByIds",
  equipmentPage = "api/aiot/equipmentType/page",
}

export function updateEquipmentTypes(data: ParDeviceTypeItem) {
  return req.commonPost<boolean>(Api.updateEquipmentTypes, data);
}
export function updateEquipmentTypesEnterprise(data: ParDeviceTypeItem) {
  return req.commonPost<boolean>(Api_aiot.updateEquipmentTypes, data);
}
export function pageEquipmentCategory() {
  return req.commonPost<PaginationResult<EquipmentCategoryItem>>(Api.pageEquipmentCategory, {
    current: 1,
    model: { searchText: "", parentCategoryId: "0" },
    size: 9999,
  });
}
export function pageEquipmentCategoryEnter() {
  return req.commonPost<PaginationResult<EquipmentCategoryItem>>(Api_aiot.pageEquipmentCategory, {
    current: 1,
    model: { searchText: "", parentCategoryId: "0" },
    size: 9999,
  });
}
export function equipmentPage() {
  return req.commonPost<PaginationResult<EquipmentTypeItem>>(Api_aiot.equipmentPage, {
    size: 9999,
    current: 1,
    model: {},
  });
}
// 平台端设备类型分页接口
// export function equipmentTypePage() {
//   return req.commonPost<PaginationResult<EquipmentTypeItem>>(Api.equipmentPage, {
//     size: 9999,
//     current: 1,
//     model: {},
//   });
// }
export function equipmentTypePage(useGlobalLoading = true) {
  return req.post<PaginationResult<EquipmentTypeItem>>(
    {
      url: Api.equipmentPage,
      data: {
        size: 9999,
        current: 1,
        model: {},
      },
    },
    {
      useGlobalLoading,
    }
  );
}
export function copyEquipmentTypes(data: Array<ParDeviceTypeItem>) {
  return req.commonPost<boolean>(Api.copyEquipmentTypes, data);
}
// 新增企业设备机型
export function addEquipmentTypes(data: ParEquipmentTypeItem) {
  return req.commonPost<boolean>(Api_aiot.addEquipmentTypes, data);
}
